package cn.school.test;

import cn.school.dao.StudentDao;
import cn.school.entity.Student;
import cn.school.util.MyBatisUtil;
import org.apache.ibatis.session.SqlSession;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author oldliu
 * @since 1.0
 */
public class SecondLevelCache {
    //加了cache设置后
    public static void main(String[] args) throws ParseException {
        SqlSession s= MyBatisUtil.get();
        StudentDao dao =s.getMapper(StudentDao.class);

//
        SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd");
        System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
        Map<String,Object> p=new HashMap<>();
        p.put("sname","李");
        p.put("start",df.parse("2017-8-1"));
        p.put("end",df.parse("2019-12-1"));
        List<Student> students = dao.search2(2, 5, p);
        students.stream().forEach(System.out::println);
        MyBatisUtil.close(s);
        SqlSession s2= MyBatisUtil.get();
        StudentDao dao2 =s2.getMapper(StudentDao.class);
        System.out.println("???????????????????????????????");
        List<Student> students2 = dao2.search2(2, 5, p);
        students2.stream().forEach(System.out::println);
        System.out.println(students==students2);
        MyBatisUtil.close(s2);
    }
}
